import com.jdbc.Account;
import com.jdbc.dao.AccountDao;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;

public class TestJDBC02 {
    @Test
    public void testQuery() {
        //初始化spring容器
        ApplicationContext context = new ClassPathXmlApplicationContext("spring-config02.xml");
        //从spring容器中获取AccountDao实例
        AccountDao dao = context.getBean(AccountDao.class);
        //调用dao的方法查询id号为3的记录并显示
        Account account = dao.findAccountById(3);
        System.out.println(account);
        System.out.println("======================");
        //调用dao的方法查询所有记录并显示
         List<Account> accounts = dao.findAllAccount();
         for (Account acc : accounts) { System.out.println(acc); } }
}
